<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>组件语法糖注册方式</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <cpn1></cpn1>
    <cpn2></cpn2>
  </div>

  <script>
    // 全局组件注册语法糖,省略了Vue.extend创建组件构造器对象
    Vue.component('cpn1', {
      template: `
        <div>
          <h2>我是标题</h2>
          <P>我是内容，哈哈哈哈</P> 
        </div>
      `
    })
    // 注册局部组件的语法糖
    var vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      components: {
        'cpn2': {
          template: `
                    <div>
                      <h2>我是标题2</h2>
                      <P>嘻嘻嘻嘻嘻嘻嘻嘻</P> 
                    </div>
                  `
        }
      }
    });
  </script>
</body>

</html>